package com.sjllb.tank;
import java.awt.*;
/**
 * 血块类，吃了血块可以增加生命值
 * @author lianlibo
 *
 */
public class Blood {
	int x;
	int y;
	int w;
	int h;
	TankClient tc;
	private boolean live = true;
	
	 // 指明血块运动的轨迹，由pos中各个点够成
	private int[][] pos = { { 300, 300 }, { 320, 300 }, { 330, 300 },
			{ 340, 300 }, { 350, 300 }, { 360, 300 }, { 370, 300 },
			{ 380, 300 }, { 375, 280 }, { 360, 290 }, { 350, 295 } };
	
	int step = 0;

	public Blood() {
		x = pos[0][0];
		y = pos[0][1];
		w = 20;
		h = 15;
	}

	public void draw(Graphics g) {
		if (!live)
			return;
		Color c = g.getColor();
		g.setColor(Color.MAGENTA);
		g.fillRect(x, y, w, h);
		g.setColor(c);

		move();
	}

	void move() {
		step++;
		if (step == pos.length) {
			step = 0;
		}
		x = pos[step][0];
		y = pos[step][1];
	}

	public Rectangle getRect() {
		return new Rectangle(x, y, w, h);
	}

	public boolean isLive() {
		return live;
	}

	public void setLive(boolean live) {
		this.live = live;
	}

}
